﻿HmJS.$Import('util.effect.Impress');
//HmJS.$Import('core.domready');

HmJS.register('demo.module.util.effect.impress', function ($ns) {
	var that = {};

	that.todo1 = function () {
		impress = new $ns.util.effect.Impress({
			opacity: .9,
			color: '#333',
			onHover: true,
			toImpressOnHover: $$('.impress')
		});

		$(document.body).addEvent('keydown', function (e) {
			if (e.key == 'esc') {
				e.stop();
				impress.activateOnHover(false);
			}
		});

		//GO TO HOMEPAGE
		document.id('logo').addEvent('click', function () {
			location.href = "http://panaghia.it";
		});
	};

	that.todo2 = function () {
		document.id('impressToggler').addEvent('click', function (e) {
			e.preventDefault();
			document.id('element2Impress').impress();
		});
	};

	that.todo3 = function () {
		var activeButton = null; //remember the current button

		var impress = new $ns.util.effect.Impress({
			opacity: .9,
			color: '#333',
			onClose: function () {
				activeButton.setStyle('backgroundColor', '#eee'); //restore state
			}
		});

		$$('.impressButton').addEvent('click', function () {
			impress.toggle(this.getParent());
			if (impress.isActive()) {
				this.setStyle('backgroundColor', '#66C7E5');
				activeButton = this;
			}
		});

		//GO TO HOMEPAGE
		document.id('logo').addEvent('click', function () {
			location.href = "http://panaghia.it";
		});
	};

	return that;
});
